pub struct Condition {
    pub field: String,     // 字段名
    pub operator: String,  // 操作符
    pub value: String,     // 操作值
}

impl Condition {
    pub fn new(field: &str, operator: &str, value: &str) -> Self {
        Condition {
            field: field.to_string(),
            operator: operator.to_string(),
            value: value.to_string(),
        }
    }

    pub fn to_sql(&self) -> String {
        let operator = self.operator.to_uppercase(); // 将操作符转换为大写
        match operator.as_str() {
            "IN" => format!("`{}` IN ({})", self.field, self.value),
            "NOT IN" => format!("`{}` NOT IN ({})", self.field, self.value),
            "LIKE" => format!("`{}` LIKE '{}'", self.field, self.value),
            ">" => format!("`{}` > '{}'", self.field, self.value),
            ">=" => format!("`{}` >= '{}'", self.field, self.value),
            "<" => format!("`{}` < '{}'", self.field, self.value),
            "<=" => format!("`{}` <= '{}'", self.field, self.value),
            _ => format!("`{}` = '{}'", self.field, self.value),
        }
    }
}